package learn.emp01.ex04;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextDouble()) {
            double x = scanner.nextDouble();
            double result = calculateSquareRoot(x);
            System.out.printf("%.6f\n",result);
        }
        scanner.close();
    }

    private static double calculateSquareRoot(double x) {
        if (x<0){
            return Double.NaN;
        }
        if (x==0){
            return 0.0;
        }
        double step = 0.0001;
        double epsilon = 0.0001;
        double result = 0.0;
        while (Math.pow(result,2)<x && Math.abs(x-Math.pow(result,2))>epsilon){
            result += step;
        }
        return result;
    }
}
